import type { AddressList } from '@/types/address'
import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useAddressStore = defineStore(
  'address',
  () => {
    const address = ref({} as AddressList)
    const count = ref<number>(0)
    const skuId = ref<string>('')
    const setAddress = (Address: AddressList) => {
      address.value = Address
    }
    const clearAddress = () => {
      address.value = {} as AddressList
    }

    const setSkuId = (id: string) => {
      skuId.value = id
    }

    const setCount = (Count: number) => {
      count.value = Count
    }
    return { address, setAddress, clearAddress, skuId, setSkuId, count, setCount }
  },
  {
    persist: true,
  },
)
